<template>
	<div class="LedtContent">
		<div class="form-view">
			<!-- 装置 -->
			<div class="form-row">
				<div class="form-row-label">
					{{ $t("message.bhView.leftComponents.device") }}
				</div>
				<div class="form-row-right-content">
					<el-select v-model="valuePlant" :placeholder="$t('message.bhView.label.placeholderSearch')
						" class="form-ipt" @change="PlantChange()" @focus="getPlantApi(1, 1000)">
						<el-option v-for="item in plantOptions" :key="item.pltCode" :label="item.pltName"
							:value="item.pltCode"></el-option>
					</el-select>
				</div>
			</div>

			<!-- 対象 -->
			<div class="form-row">
				<div class="form-row-label">
					{{ $t("message.bhView.leftComponents.object") }}
				</div>
				<div class="form-row-right-content">
					<el-select v-model="radio" :placeholder="$t('message.bhView.label.placeholderSearch')
						" class="form-ipt" @change="radioChange" @focus="getPlantApi(1, 1000)">
						<el-option :label="$t('message.bhView.leftComponents.machine')" value="1"></el-option>

						<el-option :label="$t('message.bhView.leftComponents.piping')" value="2"></el-option>
					</el-select>
				</div>
			</div>

			<!-- 搜索 -->
			<div class="form-row">
				<div class="form-row-label seach">
					<i class="el-icon-search" @click="ctgVauleSearch"></i>
				</div>
				<div class="form-row-right-content">
					<el-input v-model="ctgVaule" placeholder="" class="form-ipt"
						@keyup.enter.native="ctgVauleSearch"></el-input>
				</div>
			</div>
		</div>

		<!-- 机器番号 -->
		<div class="machine-number">
			<div class="title">
				<span v-if="radio == '1'">{{
					$t("message.bhView.leftComponents.MachineSerialNumber")
				}}</span>
				<span v-if="radio == '2'">ラインNo</span>
			</div>
			<div class="machine-number-body">
				<div class="Item" v-for="(Item, index) in drwMgtData" :key="Item.dmgCode"
					@click="ClickTableRow(Item, index)" :class="index == itemActive ? 'ItemActive' : ''">
					<div class="ItemID">{{ index + 1 }}</div>
					<div class="ItemName">
						<!-- {{ radio == "1" ? Item.macName : Item.name }} -->
						{{ Item.macName }}
					</div>

					<div class="itemStatus">
						<el-image style="
								width: 17px;
								height: 17px;
								padding: 2px;
								margin-top: 4px;
							" :src="Item.isRaMe ? checkImg : uncheckImg" fit="fill"></el-image>
					</div>
				</div>
			</div>
		</div>

		<!-- 选中的构件号 -->
		<div class="select-number">
			<ux-grid ref="multipleTable" :data="macNumberData" style="width: 100%" :header-cell-style="{
				color: 'rgba(0, 0, 0, 0.85)',
				fontSize: '14px',
				textAlign: 'left',
				fontWeight: 'bold',
				padding: 0,
				height: '32px',
			}" :cell-style="{
				color: 'rgba(96,98,102,1)',
				fontSize: '14px',
				textAlign: 'left',
				padding: 0,
				height: '32px',
			}" :row-style="{
				color: 'rgba(96,98,102,1)',
				fontSize: '13px',
				textAlign: 'left',
				padding: 0,
				height: '32px',
			}" highlight-current-row :height="tableHeight" @selection-change="handleSelectionChange"
				:element-loading-text="$t('message.bhView.loading')" :checkbox-config="{
					showHeader: false,
					checkMethod: checkMethod
				}">
				<template slot="empty"> No data </template>
				<ux-table-column type="checkbox" width="50" checkcolumn="true"> </ux-table-column>
				<ux-table-column property="partsCode" :title="$t(
					'message.smartPidPage.threeDLeftContent.column1'
				)
					">
					<template slot-scope="scope">
						<p @click="
							handleSelectNumberNameClick(
								scope.$rowIndex,
								scope.row
							)
							">
							{{ scope.row.proName }}
						</p>
					</template>
				</ux-table-column>
				<ux-table-column property="partsCode" :title="$t(
					'message.smartPidPage.threeDLeftContent.column2'
				)
					" width="55">
					<template slot-scope="scope">
						<p @click="
							handleSelectNumberNameClick(
								scope.$rowIndex,
								scope.row
							)
							" style="text-align:center;">
							{{ scope.row.linNumb }}
						</p>
					</template>
				</ux-table-column>

				<ux-table-column :title="$t(
					'message.smartPidPage.threeDLeftContent.pidTableColTitle2'
				)
					" width="60">
					<template slot-scope="scope">
						<el-button @click="
							handleSelectNumberDelClick(
								scope.$rowIndex,
								scope.row,
								scope
							)
							" type="text" size="small" :disabled="isEdit">{{ $t("message.public.delete") }}</el-button>
					</template>
				</ux-table-column>
			</ux-grid>
			<div class="select-info">
				<div class="info">
					{{
						$t("message.smartPidPage.threeDLeftContent.footTotal") +
						drwMgtData.length +
						$t("message.smartPidPage.threeDLeftContent.footerUnit")
					}}
				</div>

				<div class="info">
					{{
						$t("message.smartPidPage.threeDLeftContent.footPart") +
						raMeData.length +
						$t("message.smartPidPage.threeDLeftContent.footerUnit")
					}}
				</div>
			</div>
		</div>

		<!-- 底部信息 -->
		<div class="bh-footer">
			<el-button class="select-btn" :disabled="isEdit" @click="_cancel">
				{{ $t("message.public.cancel") }}
			</el-button>
			<el-button class="select-btn" type="primary" :disabled="isEdit" @click="_baoCun">
				{{ $t("message.public.save") }}
			</el-button>

			<el-button class="select-btn red" :class="isEdit ? 'opa' : ''" :disabled="isEdit" @click="_saveFroPFD">
				{{ $t("message.public.rela") }}
			</el-button>
		</div>
	</div>
</template>

<script>
import { getPlant, getMachine, getRelationMachine, AddMachinePFDInteractive, GetPFDDesc, getMachinePFDInfo, getMachinePFDInteractive, ralationTMsg } from "@/api/api";
import eventBus from "@/eventBus/bus";
import Template from "../../template.vue";
import { getLocalStorage } from "@/utils/storage";
import $ from "jquery";
// 导出模块
export default {
	// 模块名字
	name: "LeftContent",
	props: {
		// numberData: Number,
		// activeName: String,
		// styleOptionsValue: Number,
		selectNumberListData: [],
		isEdit: Boolean
	},
	// 模块数据
	data() {
		//数据
		return {
			proItem: {},
			radio: "1", // mactype 单选
			plantOptions: [], // 装置下拉
			valuePlant: "", // 装置选择值
			drwMgtData: [], // 机器列表
			raMeData: [], // 已绑定的机器
			number: 0, // 机器数量
			itemActive: null, // 选中机器

			ctgVaule: "", // 搜索输入关键字

			leftListRow: {}, // 选中机器

			// 机器构件数组
			macNumberData: [
				// {
				// 	partsCode: 2,
				// 	proceData: '111'

				// },
				// {
				// 	partsCode: 1090
				// },
			],

			mCheckedMacIdArray: [],
			tableHeight: 100,

			// 是否处理构件选中事件
			doThingWhenSelectNumber: true,
			selectList: [],

			checkImg: require("@/assets/img/checkbox_sel.png"),
			uncheckImg: require("@/assets/img/checkbox_unsel.png"),
			proceData: {},

			selectRow: {},
			allListDes: [],
			testAA: {},

			upDataJson: [],
			isChangePFD: false,


		};
	},
	// 注册组件
	components: { Template },
	// 监听指定值，只有指定值变化，才会触发
	watch: {

		drwMgtData(val) {
			if (val.length == 0) {
				this.macNumberData = [];
			}
		},
		mCheckedMacIdArray(nVal, oVal) {
			console.log(`watch mCheckedMacIdArray ---  ---`, nVal);
			this.$emit("checkMacArrayChange", nVal);
		},
		macNumberData(nVal, oVal) {
			console.log(this.selectList)
			eventBus.$emit("cardForReadingClick", this.selectList)
		},
		isEdit(nVal, oVal) {
			console.log(`watch mCheckedMacIdArray ---  ---`, nVal, this.upDataJson, this.macNumberData);
			console.log(this.upDataJson)
			if (nVal && this.upDataJson.length != 0) {
				this.$confirm('変更内容を保存します、宜しいですか？', '', {
					cancelButtonText: 'Cancel',
					confirmButtonText: 'OK',
					type: 'warning'
				}).then(() => {
					if (this.isChangePFD) {
						this.AddMachinePFDInteractive(true);
					} else {
						this.AddMachinePFDInteractive();
					}
				}).catch(() => {
					if (this.isChangePFD) {
						eventBus.$emit("changeID")
						this.isChangePFD = false;
						setTimeout(() => {
							this.ClickTableRow(this.leftListRow, this.itemActive)
						}, 1500);
						return
					}
					console.log("CCCCCCC")

					this.getRelationMachineApi();
					this.ClickTableRow(this.leftListRow, this.itemActive)
				});

			}
		},
		// macNumberData
		proceData(nVal, oVal) {
			console.log(nVal)
			if (this.upDataJson.length != 0) {
				this.$confirm('変更内容を保存します、宜しいですか？', '', {
					cancelButtonText: 'Cancel',
					confirmButtonText: 'OK',
					type: 'warning'
				}).then(() => {
					this.AddMachinePFDInteractive(true);
				}).catch(() => {
					if (this.isChangePFD) {
						eventBus.$emit("changeID")
						this.isChangePFD = false;
						setTimeout(() => {
							this.ClickTableRow(this.leftListRow, this.itemActive)
						}, 1500);
						return
					}
					console.log("CCCCCCC")

					this.getRelationMachineApi();
					this.ClickTableRow(this.leftListRow, this.itemActive)
				});

			}
		},
	},
	// 里面的函数只有调用才会执行（实时计算）里面是定义的方法
	methods: {
		_baoCun() {
			// this.isEdit = !this.isEdit;

			// this.isEdit = !this.isEdit;
			// this.$emit("isEdit", 1)
			if (this.upDataJson.length != 0) {
				this.$confirm('変更内容を保存します、宜しいですか？', '', {
					cancelButtonText: 'Cancel',
					confirmButtonText: 'OK',
					type: 'warning'
				}).then(() => {
					this.AddMachinePFDInteractive(true);
				}).catch(() => {
					this.upDataJson = [];
					if (this.isChangePFD) {
						eventBus.$emit("changeID")
						this.isChangePFD = false;
						setTimeout(() => {
							this.ClickTableRow(this.leftListRow, this.itemActive)
						}, 1500);
						return
					}
					console.log("CCCCCCC")

					this.getRelationMachineApi();
					setTimeout(() => {
						this.ClickTableRow(this.leftListRow, this.itemActive)
					}, 500);
				});

			}
		},
		//取消添加，削除机器部件
		_cancel() {
			this.$confirm('変更内容がキャンセルされます、よろしいですか？', '', {
				cancelButtonText: 'Cancel',
				confirmButtonText: 'OK',
				type: 'warning'
			}).then(() => {
				// this.ClickTableRow(this.leftListRow, this.itemActive);
				this.upDataJson = [];
				let dataJson = {
					MacCode: this.leftListRow.realMacCode,
					pltCode: this.leftListRow.pltCode
				}
				this.getMachinePFDInteractive(dataJson);

				// this.upDataJson = [];
				// this.upDataJson.forEach((i, v) => {
				// 	if (i.MacCode == this.leftListRow.realMacCode) {
				// 		console.log("1111")
				// 		this.upDataJson.splice(v, 1)
				// 	}
				// })
				// console.log(this.upDataJson, this.leftListRow)
			}).catch(() => {

			});
		},
		//表格方法，同种通知可以査看，不同图纸不可以选择
		checkMethod({ row }) {
			let result = [];
			if (row.proName != this.proceData.proName) {
				return false;
			} else {
				return true;
			}
		},
		_saveFroPFD() {
			// console.log(this.testAA)
			// return
			this.addTab();
			console.log("click")

		},
		async GetPFDDescApi() {
			let dataJson = { ProCode: Number(this.proceData.proCode) }
			let res = await GetPFDDesc(dataJson)
			this.allListDes = res.data.data;
		},
		//绑定修改
		async AddMachinePFDInteractive(changeID = false) {
			// let MachinePfdList  = [];
			// 		console.log(this.macNumberData)
			// 		console.log(this.allListDes)
			// 		// return
			// // this.allListDes.forEach((i,v)=>{

			// 	for(let  a = 0;a < this.macNumberData.length; a++){
			// 		// if(this.macNumberData[a].linNumb == i.prlNo){
			// 			let temp = {};
			// 			temp.ProCode = this.macNumberData[a].proName == "処理系（DWG）5" ? 14 : 13;
			// 			// temp.ProName = this.macNumberData[a].proName;
			// 			temp.LinNumb = Number(this.macNumberData[a].linNumb);
			// 			MachinePfdList.push(temp);
			// 		// }
			// 	}
			// // })
			// console.log(this.selectRow.realMacCode,"RRRRRRRRRRRRR")
			// let dataJson = [{
			// 	MacCode: Number(this.selectRow.realMacCode),
			// 	// MucName: this.selectRow.macName.toString(),
			// 	MachinePfdList
			// }]
			let res = await AddMachinePFDInteractive(this.upDataJson);
			if (changeID) {
				eventBus.$emit("changeID");
				setTimeout(() => {
					this.ClickTableRow(this.leftListRow, this.itemActive)
				}, 1500);
				console.log("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCccc")
			}
			if (res.data.code != 0) {
				this.$alert(res.data.msg, '', {
					confirmButtonText: 'OK',
					type: 'warning',
				});
				return
			}
			this.upDataJson = []
			this.$message.success(
				res.data.msg
			);
			this.getRelationMachineApi();
			console.log(res, "RRRRRRRRRRRRRRRR")
			this.ClickTableRow(this.leftListRow, this.itemActive)

			// this.leftListRow = row;
		},
		//削除
		handleSelectNumberDelClick(index, row, scope) {
			this.macNumberData.splice(index, 1)
			this.selectList.forEach((i, v) => {
				if (i.linNumb == row.linNumb && i.proName == row.proName) {
					this.selectList.splice(v, 1);
				}
			});


			let MachinePfdList = [];

			for (let a = 0; a < this.macNumberData.length; a++) {

				let temp = {};
				temp.ProCode = this.proItem.proCode;
				temp.LinNumb = Number(this.macNumberData[a].linNumb);
				MachinePfdList.push(temp);
			}
			let dataJson = {
				MacCode: Number(this.selectRow.realMacCode),
				MachinePfdList
			}
			if (this.upDataJson.length == 0) {
				this.upDataJson.push(dataJson);
			}
			var isOK = false;
			this.upDataJson.forEach((i, v) => {
				if (i.MacCode == this.selectRow.realMacCode) {
					isOK = true;
					this.upDataJson.splice(v, 1, dataJson);
				}
			})

			if (isOK) {
				return
			} else {
				this.upDataJson.push(dataJson);
			}

		},
		//多选框
		handleSelectionChange(e) {
			this.selectList = []
			this.selectList = e;
			console.log("handleSelectionChange", e)
			eventBus.$emit("cardForReadingClick", e)
		},
		//整行
		handleSelectNumberNameClick(index, row) {
			console.log(this.selectRow)
		},
		// 获取装置
		getPlantApi(pageIndex, pageSize) {
			let dataJson = {
				pltCode: 0,
				platName: "",
				pageIndex: pageIndex,
				pageSize: pageSize,
			};
			getPlant(dataJson).then((res) => {
				this.plantOptions = [];
				if (res.data.code != 0) {
					return;
				}
				this.plantOptions = res.data.data;
			});
		},
		//获取机器/配管
		getMachineApi(macCode, macName, impCode, pageIndex, pageSize, type = 1) {
			let dataJson = {
				macCode: macCode == "" ? 0 : macCode,
				macName: macName,
				pltCode:
					this.$store.state.pltCode == ""
						? 9
						: this.$store.state.pltCode,
				macType: parseInt(this.$store.state.threeRelationMacType),
				ctgCode: 0,
				impCode: impCode == "" ? 0 : impCode,
				lawCode: 0,
				pageIndex: pageIndex,
				pageSize: 9999,
				type
			};
			getMachine(dataJson).then((res) => {
				this.drwMgtData = [];
				this.number = 0;
				if (res.data.code != 0) {
					// 机器列表异常 通知上层页面选中为空
					// this.$store.commit("changeThreeRelationMacName", "");
					// this.$store.commit("changeThreeRelationMacNameb", "");
					this.$store.state.PFDName1 = "";
					this.$store.state.PFDName2 = "";
					return;
				}
				this.drwMgtData = res.data.data;
				console.log(this.drwMgtData, "DDDDDDDDDdddd")
				this.getRelationMachineApi();
				this.ClickTableRow(this.drwMgtData[0], 0)
				this.number = res.data.count;
				this.itemActive = 0;
				// this.$store.commit(
				// 	"changeThreeRelationMacName",
				// 	this.drwMgtData[0].macName
				// );
				// this.$store.commit(
				// 	"changeThreeRelationMacNameb",
				// 	this.drwMgtData[0].name
				// );
				this.$store.state.PFDName1 = this.drwMgtData[0].macName;
				this.$store.state.PFDName2 = this.drwMgtData[0].name;


				let data = {
					row: this.drwMgtData[0],
					data: this.drwMgtData,
				};
				console.log(data, "---");
			});
		},
		// 获取绑定机器
		// getRelationMachineApi(){
		// 	let dataJson = {
		// 		macType: parseInt(this.$store.state.threeRelationMacType)
		// 	};
		// 	getRelationMachine(dataJson).then(res=>{
		// 		if(res.data.code != 0){
		// 			return
		// 		}
		// 		this.raMeData = res.data.data;
		// 		console.log(this.raMeData,"已绑定的机器")
		// 		this.drwMgtData.forEach((i,v)=>{
		// 			i.isRaMe = false;
		// 			this.raMeData.forEach((j,k)=>{
		// 				if(i.macCode == j.dmgCode){
		// 					i.isRaMe = true;
		// 				}
		// 			})
		// 		})
		// 		// 页面已渲染机器列表，新增绑定状态后强制更新页面
		// 		this.$forceUpdate();
		// 	})
		// },
		getRelationMachineApi() {
			let dataJson = {
				macType: Number(this.radio)
			};
			getMachinePFDInfo(dataJson).then(res => {
				if (res.data.code != 0) {
					return
				}
				this.raMeData = res.data.data;
				console.log(this.raMeData, this.drwMgtData, "已绑定的机器")
				this.drwMgtData.forEach((i, v) => {
					i.isRaMe = false;
					this.raMeData.forEach((j, k) => {
						if (i.macName == j.macNumb) {
							i.isRaMe = true;
						}
					})
				})
				// 页面已渲染机器列表，新增绑定状态后强制更新页面
				this.$forceUpdate();
			})
		},


		//装置筛选
		PlantChange() {
			// 装置选择后更新装置code 和 名称
			this.$store.commit("changeThreeRelationPltCode", this.valuePlant);
			this.$store.commit("changePltCode", this.valuePlant);
			this.plantOptions.forEach((Item) => {
				if (Item.pltCode == this.valuePlant) {
					this.$store.commit(
						"changeThreeRelationPlantName",
						Item.pltName
					);
				}
			});
			this.getMachineApi("", "", "", 1, 1000);

			this.itemActive = null;
		},

		//点击表格行
		ClickTableRow(row, index) {
			this.itemActive = index;
			this.leftListRow = row;
			this.selectRow = row;
			console.log(this.upDataJson, "DDDDDDDDDDDDDDDDDD", this.macNumberData)
			let flg = false;
			if (this.upDataJson.length != 0) {
				this.upDataJson.forEach((i, v) => {
					console.log(i.MacCode, row.realMacCode)
					if (i.MacCode == row.realMacCode) {
						this.macNumberData = [];
						i.MachinePfdList.forEach((a, b) => {
							this.macNumberData.push({
								linNumb: a.LinNumb,
								proName: a.ProCode == 14 ? '処理系（DWG）5' : '処理系（BMP）3'
							})
						})
						flg = true;
					}
				})
			}
			if (flg) {
				return
			}
			console.log(111)

			this.selectList = [];
			console.log(row, index)


			let data = {
				row: this.leftListRow,
				data: this.drwMgtData,
			};
			// this.$store.commit("changeThreeRelationMacName", row.macName);
			// this.$store.commit("changeThreeRelationMacNameb", row.name);
			this.$store.state.PFDName1 = row.macName;
			this.$store.state.PFDName2 = row.name;
			if (this.drwMgtData.length == 0) {
				return
			}
			let dataJson = {
				MacCode: row.realMacCode,
				pltCode: row.pltCode
			}
			this.getMachinePFDInteractive(dataJson);
		},
		async getMachinePFDInteractive(dataJson) {

			let res = await getMachinePFDInteractive(dataJson);
			if (res.data.code != 0) {

				this.macNumberData = []
				eventBus.$emit("cardForReadingClick", { linNumb: -1 })

				return
			}
			// debugger

			this.macNumberData = res.data.data;
			console.log(this.macNumberData, "TTTTTTTTTTTT")
			setTimeout(() => {
				this.macNumberData.forEach((i, v) => {
					if (i.proName == this.proceData.proName) {
						this.$refs.multipleTable.toggleRowSelection([
							{
								row: this.macNumberData[v],
								selected: true
							}
						])
					} else {

						this.$refs.multipleTable.toggleRowSelection([
							{
								row: this.macNumberData[v],
								selected: false
							}
						])
					}
				})
				// this.$refs.multipleTable.clearSelection();
				// this.toggleSelection([this.macNumberData[0],this.macNumberData[1]])

			}, 300);
		},



		ctgVauleSearch() {
			this.getMachineApi("", this.ctgVaule, "", 1, 1000);
		},

		//切换机器或者配管 数据刷新
		radioChange(radio) {
			// 更新状态
			this.ctgVaule = "";

			this.$store.commit("changeThreeRelationMacType", radio);
			// if(radio == 2){
			this.getMachineApi("", this.ctgVaule, "", 1, 1000);
			// }else{
			// 	this.getMachineApi("", this.ctgVaule, "", 1, 1000);
			// }
		},
		async addTab() {
			if (this.drwMgtData.length == 0) {
				return
			}
			let inData = this.testAA;
			console.log(this.testAA)

			var flg = true;
			console.log(this.macNumberData, "DDDDDDdddd")
			console.log(inData, "DDDDDDdddd")

			if (this.macNumberData.length != 0) {
				this.macNumberData.forEach((i, v) => {
					if (i.linNumb == inData.prlNo && i.proName == this.proceData.proName) {
						flg = false;
					}
				})
			}
			if (flg && inData && inData.prlNo && this.proceData.proName) {
				var obj = {}
				obj.linNumb = inData.prlNo;
				obj.partsName = inData.name;
				obj.proName = this.proceData.proName;
				this.macNumberData.push(obj)


				let MachinePfdList = [];

				for (let a = 0; a < this.macNumberData.length; a++) {
					let temp = {};
					temp.ProCode = Number(this.macNumberData[a].proCode) || this.proItem.proCode;
					temp.LinNumb = Number(this.macNumberData[a].linNumb);
					MachinePfdList.push(temp);
				}
				console.log(this.selectRow.realMacCode, "RRRRRRRRRRRRR")
				let dataJson = {
					MacCode: Number(this.selectRow.realMacCode),
					MachinePfdList
				}
				if (this.upDataJson.length == 0) {
					this.upDataJson.push(dataJson);
				}
				var isOK = false;
				this.upDataJson.forEach((i, v) => {
					if (i.MacCode == this.selectRow.realMacCode) {
						isOK = true;
						this.upDataJson.splice(v, 1, dataJson);
					}
				})
				console.log(this.upDataJson)

				if (isOK) {
					return
				} else {
					this.upDataJson.push(dataJson);
				}

				console.log(this.upDataJson)

			} else {
				// let R = await ralationTMsg(
				// 	{ lan: parseInt(getLocalStorage("lang") == "1" ? 2 : 1) }
				// )
				// this.$alert(R.data.msg, '', {
				// 	confirmButtonText: 'OK',
				// 	type: 'warning',
				// });
			}


		}
	},
	// 创建前状态(里面是操作)
	beforeCreate() { },
	// 创建完毕状态(里面是操作)
	created() {
		//默认添加装置
		let dataJson = {
			pltCode: 0,
			platName: "",
			pageIndex: 1,
			pageSize: 1000,
		};
		getPlant(dataJson).then((res) => {
			this.plantOptions = [];
			if (res.data.code != 0) {
				return;
			}
			this.plantOptions = res.data.data;

			if (this.$store.state.pltCode) {
				this.valuePlant = this.$store.state.pltCode;
			} else {
				this.valuePlant = this.plantOptions[0].pltCode;
				this.$store.commit(
					"changePltCode",
					this.valuePlant
				);
				this.$store.commit(
					"changeThreeRelationPltCode",
					this.valuePlant
				);
			}

			this.plantOptions.forEach((Item) => {
				if (Item.pltCode == this.valuePlant) {
					this.$store.commit(
						"changeThreeRelationPlantName",
						Item.pltName
					);
				}
			});
			this.getMachineApi("", this.ctgVaule, "", 1, 1000);
			// this.getRelationMachineApi();
		});

	},
	// 挂载前状态(里面是操作)
	beforeMount() {
		eventBus.$pff("_getProcessor")
		eventBus.$pff("pfdRelationSelectTableRow")

	},
	// 挂载结束状态(里面是操作)
	mounted() {
		this.tableHeight = $(".select-number").height() - 34.5;

		eventBus.$on("pfdRelationSelectTableRow", (inData) => {
			console.log(inData)
			console.log(this.isEdit)
			// if(!this.isEdit){

			try {
				if (inData.prlNo) {
					this.testAA = inData;
				}
			} catch (error) {
				//
			}
			console.log(this.testAA)



		});

		eventBus.$on("_getProcessor", (e) => {
			this.proceData = e;
			if (this.upDataJson.length != 0) {
				// this.$confirm('変更内容を保存します、宜しいですか？', '', {
				// 		cancelButtonText: 'Cancel',
				// 		confirmButtonText: 'OK',
				// 		type: 'warning'
				// 	}).then(() => {
				// 		this.AddMachinePFDInteractive(true);
				// 	}).catch(() => {
				// 		this.upDataJson = [];
				// 		eventBus.$emit("changeID");
				// 	});

			} else {
				eventBus.$emit("changeID");
				setTimeout(() => {
					// this.macNumberData.forEach((i,v)=>{
					// 	if(i.proName == this.proceData.proName){
					// 		this.$refs.multipleTable.toggleRowSelection([
					// 			{
					// 			row: this.macNumberData[v],
					// 			selected: true
					// 			}
					// 		])
					// 	}else{

					// 		this.$refs.multipleTable.toggleRowSelection([
					// 			{
					// 			row: this.macNumberData[v],
					// 			selected: false
					// 			}
					// 		])
					// 	}
					// })
					this.ClickTableRow(this.leftListRow, this.itemActive)
				}, 1500);
			}
			// this.isChangePFD = true;
			console.log(e, "EEEEEEEEEEEEEEEe")
			this.proItem = e;
			// setTimeout(() => {
			// 	this.macNumberData.forEach((i,v)=>{
			// 		if(i.proName == this.proceData.proName){
			// 			this.$refs.multipleTable.toggleRowSelection([
			// 				{
			// 				row: this.macNumberData[v],
			// 				selected: true
			// 				}
			// 			])
			// 		}else{

			// 			this.$refs.multipleTable.toggleRowSelection([
			// 				{
			// 				row: this.macNumberData[v],
			// 				selected: false
			// 				}
			// 			])
			// 		}
			// 	})
			// }, 1500);
		})
	},
	// 更新前状态(里面是操作)
	beforeUpdate() { },
	// 更新完成状态(里面是操作)
	updated() {
		// 使用querySelectorAll选中所有带有.elx-cell--checkbox类的元素
		var elements = document.querySelectorAll('.elx-cell--checkbox');

		// 遍历这些元素  
		elements.forEach(function (element) {
			// 修改每个元素的title属性  
			element.setAttribute('title', '');
		})
	},
	// 销毁前状态(里面是操作)
	beforeDestroy() { },
	// 销毁完成状态(里面是操作)
	destroyed() { },
};
</script>
<style lang="scss" scoped>
.LedtContent {
	width: 100%;
	height: 100%;
	//     background: rosybrown;
	display: flex;
	justify-content: space-between;
	flex-direction: column;
}

.form-view {
	padding-right: 24px;
	padding-bottom: 0px;
	padding-left: 0px;

	box-sizing: border-box;

	.form-row {
		width: 100%;
		height: 24px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 12px;

		.seach {
			width: 24px;
			height: 24px;
			border-radius: 4px;
			border: 1px solid #d9d9d9;
			display: flex;
			align-items: center;
			justify-content: center;
			cursor: pointer;
		}

		.form-row-label {
			color: rgba(0, 0, 0, 0.85);
			//   font-weight: 500;
		}

		.form-row-right-content {
			width: 85%;

			.form-ipt {
				width: 100%;
				height: 24px;

				::v-deep .el-input__inner {
					height: 24px;
					background: #fff;
				}

				::v-deep .el-input__icon {
					line-height: 24px;
				}
			}

			.ClearBtn {
				min-width: 66px;
				height: 24px;
				border-radius: 4px;
				display: flex;
				justify-content: center;
				align-items: center;
				border: 1px solid #eaeaeb;
				background: #106ebe;
				color: #fff;
				float: right;
			}
		}
	}

	.form-checkbox {
		padding: 0 0 12px 44px;
	}
}

.machine-number {
	width: calc(100% - 24px);
	height: calc(47% - 0px);
	border: 1px solid #c3c3c3;
	margin-left: 0px;
	box-sizing: border-box;

	.title {
		width: 100%;
		height: 32px;
		font-size: 14px;
		color: rgba(0, 0, 0, 0.85);
		background: #e9e9e9;
		display: flex;
		align-items: center;
		justify-content: center;
		border-bottom: 1px solid rgba(195, 195, 195, 0.3);
	}

	.machine-number-body {
		width: 100%;
		height: calc(100% - 32px);
		overflow: hidden;
		overflow-y: auto;

		.Item {
			display: flex;
			align-items: center;
			justify-content: flex-start;
			width: 100%;
			height: 24px;
			cursor: pointer;
			border-bottom: 1px solid rgba(195, 195, 195, 0.3);
			background: #ffffff;
			transition: 0.5s;

			.ItemID {
				width: 71px;
				height: 24px;
				border-right: 1px solid rgba(195, 195, 195, 0.3);
				display: flex;
				align-items: center;
				justify-content: center;
				color: rgba(0, 0, 0, 0.85);
			}

			.ItemName {
				padding-left: 24px;
				height: 100%;
				color: rgba(0, 0, 0, 0.65);
				display: flex;
				align-items: center;
				border-right: 1px solid rgba(195, 195, 195, 0.3);
				width: 100%;
			}

			.itemStatus {
				width: 71px;
				height: 24px;
				padding-left: 17px;
			}
		}

		.Item:hover {
			background: rgb(255, 241, 240);
		}

		.ItemActive {
			background: rgb(255, 241, 240);
		}
	}
}

.select-number {
	width: calc(100% - 24px);
	height: calc(28% - 0px);
	border: 1px solid #c3c3c3;
	margin-left: 0px;
	box-sizing: border-box;

	.select-info {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-around;
		width: calc(100%);
		background-color: #edeeef;
		padding: 6px 0px;

		.info {
			font-size: 14px;
			color: rgba(0, 0, 0, 0.65);
		}
	}
}

.bh-footer {
	height: 38px;
	display: flex;
	align-items: center;
	justify-content: space-between;

	padding: 0px 24px;
	padding-left: 0px;

	.select-btn {
		width: 90px;
		height: 30px;
		// border: 1px solid #eaeaeb;
		// border-radius: 4px;
		line-height: 2px;
	}

	.select-btn:nth-child(2) {
		transform: translateX(-25px)
	}

	.gray {
		// color: rgb(89, 89, 89);
		background: #e9e9e9;
	}

	.blue {
		color: #fff;
		background: #106ebe;
	}

	.red {
		color: #fff;
		background: #bc000f;
	}

	.opa {
		opacity: .5;
	}
}

::v-deep .el-radio {
	margin-right: 24px;
}

::v-deep .el-radio:last-child {
	margin-right: 0;
}
</style>
